function hsi = rgb2hsi(rgb)
    % 获取图像的尺寸
    [rows, cols, ~] = size(rgb);
    
    % 初始化 HSI 图像
    hsi = zeros(rows, cols, 3);
    
    % 归一化 RGB 值
    rgb = im2double(rgb);
    R = rgb(:,:,1);
    G = rgb(:,:,2);
    B = rgb(:,:,3);
    
    % 计算 I 分量
    I = (R + G + B) / 3;
    
    % 计算 S 分量
    min_rgb = min(min(R, G), B);
    S = 1 - 3 ./ (R + G + B + eps) .* min_rgb;
    
    % 计算 H 分量
    num = 0.5 * ((R - G) + (R - B));
    den = sqrt((R - G).^2 + (R - B).*(G - B));
    theta = acos(num ./ (den + eps));
    
    H = theta;
    H(B > G) = 2 * pi - H(B > G);
    H = H / (2 * pi);
    
    % 组合 HSI 图像
    hsi(:,:,1) = H;
    hsi(:,:,2) = S;
    hsi(:,:,3) = I;
end